package com.project.controller;

import com.project.entity.po.Flow;
import com.project.result.ResponseResult;
import com.project.service.FlowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/flow")
public class flowController {
    @Resource
    FlowService flowService;

    /**
     * 查询所有流水
     * @return
     */
    @GetMapping("/select/all/flow")
    public ResponseResult<List<Flow>> selectAllFlow(){
       return flowService.selectAllFlow();

    }

    /**
     * 根据菜名进行模糊查询
     * @param name
     * @return
     */
    @GetMapping("/select/flow/name")
    public ResponseResult<List<Flow>> selectFlowByName(String name){
        return flowService.selectFlowByName(name);
    }

    /**
     * 根据ID删除流水信息
     * @return
     */
    @PostMapping("/update/flow/id")
    public ResponseResult<Integer> updateFlowById(Long id){
        return flowService.updateFlowById(id);
    }

    /**
     * 根据id查询流水信息
     * @param id
     * @return
     */
    @GetMapping("/select/flow/id")
    public ResponseResult<Flow> selectFlowById(Long id){
        return flowService.selectFlowById(id);
    }

    /**
     * 添加流水信息
     * @param flow
     * @return
     */
    @PutMapping("/insert/flow")
    public ResponseResult<Integer> insertFlow(@RequestBody Flow flow){
        return flowService.insertFlow(flow);
    }

    /**
     * 修改流水信息
     * @param flow
     * @return
     */
    @PostMapping("/update/flow")
    public ResponseResult<Integer> updateFlow(@RequestBody Flow flow){
        return flowService.updateFlow(flow);
    }
}
